package com.hdoit.kylin.web.studentManager.providers;

import java.util.ArrayList;
import java.util.List;

import com.hdoit.kylin.logical.group.model.Project;
import com.hdoit.kylin.logical.group.service.IGroupService;
import com.hdoit.kylin.logical.group.service.IProjectService;
import com.hdoit.kylin.selfcommon.enums.postgraduate.MidCheckState;
import com.tennetcn.common.aop.CommonApplicationContextUtil;
import com.tennetcn.common.message.ListItem;
import com.tennetcn.component.attribute.provider.ISingleOptionListProvider;
import com.tennetcn.component.web.SessionWebFactory;
import com.tennetcn.web.cbase.providers.base.EnumConstantProvider;

public class ProjectProvider extends EnumConstantProvider<MidCheckState> implements ISingleOptionListProvider<ListItem>{
	@Override
	public List<ListItem> getDataList(Object viewData){
		List<Project> projects = getProject();
		if(projects==null || projects.size()<=0){
			return null;
		}
		dataList = new ArrayList<ListItem>();
		ListItem listItem = null;
		for(Project project : projects){
			listItem = new ListItem();
			listItem.setText(project.getProjectName());
			listItem.setValue(project.getProjectId());
			
			dataList.add(listItem);
		}
		
		return dataList;
	}
	
	private List<Project> getProject(){
		IGroupService groupService = CommonApplicationContextUtil.getCurrentContext().getBean(IGroupService.class);
		SessionWebFactory sessionWebFactory  =CommonApplicationContextUtil.getCurrentContext().getBean(SessionWebFactory.class);
		IProjectService projectService = CommonApplicationContextUtil.getCurrentContext().getBean(IProjectService.class);
//		if(groupService.queryModelByLoginId(sessionWebFactory.getCurrentLogin().getloginid())==null)
//			return null;
//		string groupid = groupservice.querymodelbyloginid(sessionwebfactory.getcurrentlogin().getloginid()).getgroupid();
//		return projectservice.querylistbygroupid(groupId);
		return null;
	}
}
